package com.movie.modules.jf.service.impl;

import com.movie.common.utils.NumberUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.movie.common.utils.PageUtils;
import com.movie.common.utils.Query;

import com.movie.modules.jf.dao.BannerDao;
import com.movie.modules.jf.entity.BannerEntity;
import com.movie.modules.jf.service.BannerService;
import org.springframework.transaction.annotation.Transactional;


@Service("bannerService")
@Transactional
public class BannerServiceImpl extends ServiceImpl<BannerDao, BannerEntity> implements BannerService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Integer sortNum= NumberUtils.objToInteger(params.get("sortNum"));
        IPage<BannerEntity> page = this.page(
                new Query<BannerEntity>().getPage(params),
                new QueryWrapper<BannerEntity>().orderByDesc(sortNum!=null,"sort_num").orderByDesc("banner_id")
        );

        return new PageUtils(page);
    }

}